from PIL import Image, ImageDraw

# 创建一个800x600的白色背景图片
width, height = 800, 600
img = Image.new('RGB', (width, height), 'white')
draw = ImageDraw.Draw(img)

# 绘制方形
square_size = 150
square_x = (width - square_size) // 2
square_y = (height - square_size) // 2
draw.rectangle(
    [(square_x, square_y), 
     (square_x + square_size, square_y + square_size)],
    fill='skyblue', 
    outline='black', 
    width=3
)

# 绘制圆形
circle_radius = 70
circle_x = width // 2
circle_y = height // 2
draw.ellipse(
    [(circle_x - circle_radius, circle_y - circle_radius), 
     (circle_x + circle_radius, circle_y + circle_radius)],
    fill='salmon', 
    outline='black', 
    width=3
)

# 保存并显示图片
img.save('square_and_circle.png')
print("图片已保存为 square_and_circle.png")
img.show()